package org.kealinghornets.jchuah.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Toast;

public class MyActivity extends Activity {

    int numcleared = 0;

        public void onButtonPush(final View viewThatWasPushed) {
            Log.d("org.kealinghornets.jchuah.myapplication" , "button pushed");

            Toast.makeText(this , "button pushed" , Toast.LENGTH_LONG).show();

            startActivity(new Intent(this , MyActivity3.class));




        Animation fade_out_animation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
        fade_out_animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                viewThatWasPushed.setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                viewThatWasPushed.setEnabled(true);
                viewThatWasPushed.setAlpha(0);
                viewThatWasPushed.clearAnimation();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        if (viewThatWasPushed.getAlpha() == 1) {
            viewThatWasPushed.startAnimation(fade_out_animation);

            numcleared = numcleared + 1;
        } else {
            viewThatWasPushed.setAlpha(1);

            numcleared = numcleared - 1;
        }


        String clockName = getResources().getResourceEntryName(viewThatWasPushed.getId());
        int clockRow = Integer.parseInt(clockName.charAt(5) + "");
        int clockColumn = Integer.parseInt(clockName.charAt(6) + "");
        Log.d("clock", "row" + clockRow + " column " + clockColumn);



        int getRow = 3;
        int getColumn = 2;
        View otherClock = ((View)viewThatWasPushed.getParent()).findViewById(getResources().getIdentifier("clock" + getRow + getColumn, "id", getPackageName()));


        if (numcleared == 10) {
        }




    }






    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);


    }
}
